package shared.pojo.mission

import shared.Pojo._
import shared.pojo.Soft._
import shared.tool.DefaultPickle
import upickle.default._
import shared.implicits.Implicits._

/** Created by yz on 15/5/2023
  */
object VolcanoPlot extends VolcanoPlotT {

  def pngFileNamePrefixIn = {
    s"Volcano_Plot"
  }

  def pngFileNamePrefix(idStr: String) = {
    if (idStr.nonBlank) {
      s"${idStr}/${pngFileNamePrefixIn}"
    } else {
      s"${pngFileNamePrefixIn}"
    }
  }

  def configFileName = {
    s"${name}.json"
  }

  case class LayoutData(
      showSample: String = "F",
      varNames: List[String] = List.empty,
      hasBorder: String = "F",
      width: String = "7",
      height: String = "5"
  )

  object LayoutData {
    implicit val rw = macroRW[LayoutData]
    implicit val defaultRw = DefaultPickle.macroRW[LayoutData]
  }

  case class ColorData(
      up: String = "#ff0000",
      down: String = "#0000ff",
      none: String = "#BEBEBE"
  )

  object ColorData {
    implicit val rw = macroRW[ColorData]
    implicit val defaultRw = DefaultPickle.macroRW[ColorData]
  }

  case class FontData(
      fontFamily: String = "Times",
      xFont: String = "9",
      xTitleFont: String = "11",
      yFont: String = "8.8",
      yTitleFont: String = "11",
      mainTitle: String = "",
      mainTitleFont: String = "13",
      legendFont: String = "9",
      legendTitle: String = "",
      legendTitleFont: String = "11"
  )

  object FontData {
    implicit val rw = macroRW[FontData]
    implicit val defaultRw = DefaultPickle.macroRW[FontData]
  }

  case class Request(
      id: Int = 0,
      idStr: String = "",
      kind: String = s"${name}",
      layout: LayoutData = LayoutData(),
      color: ColorData = ColorData(),
      font: FontData = FontData()
  )

  object Request {
    implicit val rw = macroRW[Request]
    implicit val defaultRw = DefaultPickle.macroRW[Request]
  }

}
